/**
 * 自定义装饰器
 */

import { createParamDecorator, ExecutionContext } from "@nestjs/common";

/**
 * 获取用户信息
 */
export const getUserInfo = createParamDecorator((data: string, ctx: ExecutionContext) => {
  const result = ctx.switchToHttp().getRequest();
  const user = result.user;
  if (!user) return;
  return data ? user[data] : user;
})